/* Copyright (c) 2024 Huawei Technologies Co., Ltd.
 * This file is a part of the CANN Open Software.
 * Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
 * Please refer to the License for details. You may not use this file except in compliance with the License.
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
 * See LICENSE in the root of the software repository for the full text of the License.
 * ===================================================================================================================*/

#include "exe_graph/runtime/op_execute_context.h"
#include "exe_graph/runtime/gert_mem_allocator.h"
#include "graph/ge_error_codes.h"
#include <gtest/gtest.h>
#include "faker/kernel_run_context_faker.h"
#include "faker/allocator_faker.h"
#include "exe_graph/runtime/storage_shape.h"
#include "register/kernel_registry.h"
namespace gert {
class OpExecuteContextUT : public testing::Test {};
TEST_F(OpExecuteContextUT, MallocFreeWorkSpaceOk) {
  std::vector<GertMemBlock *> mem_block;
  AllocatorFaker *gert_allocator = new AllocatorFaker();
  auto context_holder = KernelRunContextFaker()
                            .IrInputNum(2)
                            .IrInstanceNum({1, 1})
                            .KernelIONum(7, 1)
                            .NodeIoNum(2, 1)
                            .Inputs({nullptr, nullptr, nullptr, gert_allocator, nullptr, nullptr, nullptr})
                            .Outputs({&mem_block})
                            .Build();
  auto context = context_holder.GetContext<OpExecuteContext>();
  ASSERT_NE(context, nullptr);
  ASSERT_NE(context->MallocWorkspace(1024), nullptr);
  context->FreeWorkspace();
  delete gert_allocator;
}
}
